from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, declarative_base

DATABAST_URL = "mysql+pymysql://root:123456@localhost:3306/wlinfo?charset=utf8mb4"

POOL_SIZE = 20

engine = create_engine(
    DATABAST_URL,
    pool_size = POOL_SIZE
)

SessionLocal = sessionmaker(bind=engine, autocommit=False, autoflush=False)

Base = declarative_base()

def get_db():
    db = SessionLocal()
    try:
        yield db
    finally:
        db.close()